package com.example.appxi;

import java.util.StringTokenizer;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PlaceActivity extends ParentActivity {

	
	int Hot=20;
	Intent intent;
	String[] place_info;

	
	
    @SuppressLint("NewApi")
	@Override
    protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState); 
    	setContentView(R.layout.activity_place);
    	
    	
		intent=getIntent();
		Bundle R_data = intent.getExtras();
		place_info = R_data.getStringArray("place_info");
    	
    	//서버에 요청하는 구간
    	
//    	StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitNetwork().build());
//    	
//    	String[] rows = HttpRequest.get("http://dev.ts.hs.kr/trend/get_places.php").body().split(",");	
//    	String[] hot_places_rows = HttpRequest.get("http://dev.ts.hs.kr/trend/get_hot_places.php").body().split("\n");
    	
    	//서버에 요청하는 구간
    	TextView placename = (TextView) findViewById(R.id.placename);
    	TextView placeadress = (TextView) findViewById(R.id.placeloca);
    	TextView where = (TextView) findViewById(R.id.where);
  
	    	placename.setText(place_info[2]);
	    	placeadress.setText(place_info[4]);
	    	where.setText(place_info[1]);

    	
	    	
	    
    	
    	//여기서 부터는 주변추천과 실시간 핫을 만듦
    	
    	LinearLayout vertiissue = (LinearLayout) findViewById(R.id.thisisplace);
        
   	 LinearLayout.LayoutParams bannerParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   	 bannerParams.setMargins(0, 0, 0, 20);
   	 
   	 LinearLayout.LayoutParams firstParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 90);
   	 firstParams.setMargins(20, 0, 20, 0);
   	 
   	 LinearLayout.LayoutParams secondParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   	 secondParams.setMargins(20,0,20,20);
   	 
   	 LinearLayout.LayoutParams lastParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 90);
   	 lastParams.setMargins(2, 0, 2, 0);
   	 
   	 
   	 LinearLayout.LayoutParams firstinParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 10);
   	 LinearLayout.LayoutParams firstinParams2 = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 25);
   	 LinearLayout.LayoutParams lastinParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 35);
		
   	 for(int i=0;i<=9;i++){
   	 
   	 int bannercolor = 0x33AA00AA;
   	 LinearLayout actualbanner = new LinearLayout(this);
   	 actualbanner.setOrientation(LinearLayout.VERTICAL);
   	 actualbanner.setBackgroundColor(bannercolor);
   	 actualbanner.setLayoutParams(bannerParams);
   	 
   	 
   	 LinearLayout firstline = new LinearLayout(this);
   	 firstline.setOrientation(LinearLayout.HORIZONTAL);
   	 firstline.setLayoutParams(firstParams);
   	 firstline.setGravity(Gravity.CENTER);
   	 
   	 

   	 LinearLayout textview= new LinearLayout(this);
  		 textview.setClickable(true);
  		 textview.setLayoutParams(firstinParams);
  		 textview.setOrientation(LinearLayout.VERTICAL);
  		 textview.setGravity(Gravity.CENTER);

   	 
   	 
   	 
   	 LinearLayout buttonplace= new LinearLayout(this);
  		 buttonplace.setBackgroundResource(R.drawable.selector_xml_tab3);
  		 buttonplace.setClickable(true);
  		 buttonplace.setLayoutParams(firstinParams2);
  		 buttonplace.setOrientation(LinearLayout.VERTICAL);
  		 buttonplace.setGravity(Gravity.CENTER);

		 
		 
	     LinearLayout buttonperson= new LinearLayout(this); 
  		 buttonperson.setBackgroundResource(R.drawable.selector_xml_tab3);
  		 buttonperson.setClickable(true);
  		 buttonperson.setLayoutParams(firstinParams);
  		 buttonperson.setOrientation(LinearLayout.VERTICAL);
  		 buttonperson.setGravity(Gravity.CENTER);



  		 firstline.addView(textview);
  		 firstline.addView(buttonplace);
  		 firstline.addView(buttonperson);
		 
   	 
   	 TextView type = new TextView(this);
   	 type.setText("2014/5/1/11:17");
   	 type.setTextSize(9);

   	 
   	 TextView place = new TextView(this);
   	 place.setText("대구영재고");
   	 place.setGravity(Gravity.CENTER);
   	 place.setTextColor(0x45A0522D);

   	 
   	 TextView person = new TextView(this);
   	 person.setText("박찬후만만만ㅅ세");
   	 person.setGravity(Gravity.CENTER);

   	 
   	 
   	 textview.addView(type);
   	 buttonplace.addView(place);
   	 buttonperson.addView(person);
   	 
   	 
   	 
   	 LinearLayout secondline = new LinearLayout(this);
   	 secondline.setOrientation(LinearLayout.VERTICAL);
   	 secondline.setLayoutParams(secondParams);
   	 
   	 
   	 TextView textcontent = new TextView(this);
   	 textcontent.setText("박박찬후는 박박찬후고 박박찬후이며 신종민은 신종민이고 신쫑짱이니라.");
   	 textcontent.setTextSize(25);
   	 textcontent.setGravity(Gravity.CENTER);
   	 textcontent.setTextColor(0xCF000000);
   	 
   	 secondline.addView(textcontent);

   	 
   	 
   	 
   	 LinearLayout lastline = new LinearLayout(this);
   	 lastline.setOrientation(LinearLayout.HORIZONTAL);
   	 lastline.setLayoutParams(lastParams);
   	 
   	 
	    LinearLayout buttonreport = new LinearLayout(this); 
  		 buttonreport.setBackgroundResource(R.drawable.selector_xml_tab2);
  		 buttonreport.setClickable(true);
  		 buttonreport.setLayoutParams(firstinParams);
  		 buttonreport.setOrientation(LinearLayout.VERTICAL);
  		 buttonreport.setGravity(Gravity.CENTER); 
   	 
	    LinearLayout buttonreply = new LinearLayout(this); 
  		 buttonreply.setBackgroundResource(R.drawable.selector_xml_tab2);
  		 buttonreply.setClickable(true);
  		 buttonreply.setLayoutParams(lastinParams);
  		 buttonreply.setOrientation(LinearLayout.VERTICAL);
  		 buttonreply.setGravity(Gravity.CENTER);
  		 
	    LinearLayout buttonlike = new LinearLayout(this); 
  		 buttonlike.setBackgroundResource(R.drawable.selector_xml_tab2);
  		 buttonlike.setClickable(true);
  		 buttonlike.setLayoutParams(firstinParams);
  		 buttonlike.setOrientation(LinearLayout.VERTICAL);
  		 buttonlike.setGravity(Gravity.CENTER);
  		 
  		 TextView reply = new TextView(this);
   	 reply.setText("이  현수막에  낙서하기");
   	 reply.setTextSize(15);
   	 reply.setTextColor(0x65000000);
   	 reply.setGravity(Gravity.CENTER);
   	 
  		 buttonreply.addView(reply);
   	
   	 lastline.addView(buttonreport);
   	 lastline.addView(buttonreply);
   	 lastline.addView(buttonlike);
   	 
   	 
   	 

   	 
   	 actualbanner.addView(firstline);
   	 actualbanner.addView(secondline);
   	 actualbanner.addView(lastline);
   	 

   	 vertiissue.addView(actualbanner);
   		 
   	 }
  
  
        top=this;

    }

 
   

    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        //getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    
    
   
    
    
    /**
     * A placeholder fragment containing a simple view.
     */
//    public static class PlaceholderFragment extends Fragment {
//
//        public PlaceholderFragment() {
//        }
//
//        @Override
//        public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                Bundle savedInstanceState) {
//            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
//            
//            MainActivity.btn_search = (Button)rootView.findViewById(R.id.btn_search);
//
//            MA.finishSet();
//            return rootView;
//        }
//    }
//
//}
    
}
